import axios from '@utils/http/axios'

export interface category1 {
    id?: number
    name: string
    category1Id?: number
}

export interface category2 {
    id?: number,
    name: string,
    category1Id: number
}

export interface category3 {
    id?: number,
    name: string,
    category2Id: number
}

export interface allCategory {
    id?: number
    attrName: string
    categoryId: number
    categoryLevel: number
    attrValueList: {
        id: number
        valueName: string
        attrId: number
    }
}

// 获取一级分类
export const getCategory1ListApi = () => {
    return axios.get<any, category1[]>(`/admin/product/getCategory1`)
}
// 获取二级分类
export const getCategory2ListApi = (category1Id: number) => {
    return axios.get<any, category2[]>(`/admin/product/getCategory2/${category1Id}`)
}

// 获取三级分类
export const getCategory3ListApi = (category2Id: number) => {
    return axios.get<any, category3>(`/admin/product/getCategory3/${category2Id}`)
}

//获取平台属性列表
export const getPlatformAttributeListApi = (category1Id: number, category2Id: number, category3Id: number) => {
    return axios.get<any, allCategory>(`/admin/product/attrInfoList/${category1Id}/${category2Id}/${category3Id}`)
}